<?php
namespace app\home\controller;

use app\common\HomeBase;
/**
 * @title 首页
 * @description 接口说明
 * @group 西红柿
 */
class Index extends HomeBase
{
	/**
     * @title 首页展示
     * @author 雪飞鸟
     * @description 响应数据：账户余额、推广人数、累计收益、今日收入
     * @url /home/Index/index
     * @method GET
     * @param name:token type:string require:1 default:无 other: desc:15054639bfc32b4ac6d3df672753f0d8e
     * @return user_gold:6.50  
     * @return extendsN:0
     * @return hisGetSum:0
     * @return todayGetSum:0
     */
    public function index()
    {
        $user 		= $this->user;
        $uId  		= $user['user_id'];
        $time 		= date('Y-m-d');
        $extensionN = db('user')->where(['user_parent' => $uId])->count();
        $getSum 	= db('red_packet')->where(['user_id' => $uId, 'type' => 1])->sum('money');
        $getTodySum = db('red_packet')->where(['user_id' => $uId, 'type' => 1, 'create_time' => ['gt',$time]])->sum('money');
        $arr['user_gold'] 	= $user['user_gold'];
        $arr['extendsN']	= $extensionN;
        $arr['hisGetSum']	= $getSum;
        $arr['todayGetSum'] = $getTodySum;
        return json_success($arr);
    }
}
